package com.cskaoyan.controller.admincontroller;

import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.chaosbean.stat.vo.SGoodsVO;
import com.cskaoyan.bean.chaosbean.stat.vo.SOrdersVO;
import com.cskaoyan.bean.chaosbean.stat.vo.SUserVO;
import com.cskaoyan.service.adminservice.StatService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jackX
 * @datetime 2022/12/31 10:01
 * @description: TODO:
 */
@RestController
@RequestMapping("admin/stat")
public class StatController {
    @Autowired
    StatService statService;
    //请求网址: http://localhost:8083/admin/stat/user

    /**
     * 统计报表的用户统计
     *
     * @return
     */
    @RequiresPermissions("admin:stat:user")
    @GetMapping("user")
    public BaseRespVo user() {
        SUserVO userVO = statService.selectUser();
        return BaseRespVo.okYa(userVO);
    }

    /**
     * 统计报表的订单统计
     *
     * @return
     */
    @RequiresPermissions("admin:stat:order")
    @GetMapping("order")
    public BaseRespVo order() {
        SOrdersVO ordersVO = statService.selectOrder();
        return BaseRespVo.okYa(ordersVO);
    }

    /**
     * 统计报表的商品
     *
     * @return
     */
    @RequiresPermissions("noPermission:just*")
    @RequestMapping("goods")
    public BaseRespVo goods() {
        SGoodsVO goodsVO = statService.selectGoods();
        return BaseRespVo.okYa(goodsVO);
    }
}
